<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>定时器是否准时执行</title>
  <script type="text/javascript">
    window.onload = function () {
        var start = Date.now();
        setTimeout(function (){
            console.log("dingshiqi...",Date.now() - start);//dingshiqi... 8677
        },2000);
        console.log('开始循环')
        //这里的初始化循坏代码，就导致了定时器的延迟执行
        for (let i = 0; i < 10000000000; i++) {

        }
    }
  </script>
</head>
<body>

</body>
</html>